<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="resource/js/jquery-3.2.1.js"></script>
<link href="/resource/css/bootstrap.css" rel="stylesheet">

</head>
<body>

		<div class="btn-group">
			<c:if test="${pg.total==0}">
				<i>暂无数据</i>
			</c:if>

			<c:if test="${pg.total!=0}">
				<ul class="nav">
					<li class="nav-item">
						<a class="nav-link" href="#" active>共 ${pg.total} 条信息</a>
					</li>
				</ul>
				<input type="number" name="pageSize" value="${pg.pageSize}" placeholder="每页显示" style="width: 88px">
				<input class="btn btn-outline-primary" style="width: 60px" value="确定" onclick="goSize()">
				&emsp;
				<c:if test="${pg.pageNum!=1}">
					<button type="button" class="btn btn-outline-primary" onclick="goPage(1)">首页</button>
				</c:if>
				<button type="button" class="btn btn-outline-primary" onclick="goPage(${pg.prePage==0?1:pg.prePage})">&laquo;
				</button>
				<c:forEach items="${pg.navigatepageNums}" var="n">
					<button type="button" class="btn btn-outline-primary" onclick="goPage(${n})">${n}</button>
				</c:forEach>
				<button type="button" class="btn btn-outline-primary" onclick="goPage(${pg.nextPage==0?pg.pages:pg.nextPage})">
					&raquo;
				</button>
				<c:if test="${pg.pageNum!=pg.pages}">
					<button type="button" class="btn btn-outline-primary" onclick="goPage(${pg.pages})">尾页</button>
				</c:if>
				<ul class="nav">
					<li class="nav-item">
						<a class="nav-link" href="#">合计：${pg.pageNum}/${pg.pages}页</a>
					</li>
				</ul>
				<input type="number" name="pageNum" value="${pg.pageNum}" placeholder="跳转至..." style="width: 88px">
				<input class="btn btn-outline-primary me-md-2" type="button" value="跳转" onclick="goNum()">
			</c:if>
		</div>
		<script>
			function goPage(val) {
				$("[name='pageNum']").val(val);
				$("form").submit();
			}

			function goNum() {
				let val1 = $("[name='pageNum']").val();
				let val2 = $("[name='pageSize']").val();
				if (val1 > 0 && val2 > 0) {
					$("form").submit();
				} else {
					alert("温馨提示：当前页及每页显示条数必须大于0..")
				}
			}

			function goSize() {
				let val1 = $("[name='pageNum']").val();
				let val2 = $("[name='pageSize']").val();

				if (val1 > 0 && val2 > 0) {
					$("form").submit();
				} else {
					alert("温馨提示：当前页及每页显示条数必须大于0..")
				}
			}
		</script>

</body>
</html>




